package com.lgkj.ui.main;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;

/**
 * com.jincheng.hjx.lotteryfilter.framework Created by hjx on 2017/4/11 19:56
 *
 * @Company:
 * @Description: ${TODO}
 * @Email:1263276841@qq.com
 * @Version $Rev$
 * @UpdateAuthor $Author$ on 2017/4/11$
 * @UpdateDes ${TODO}
 */

public abstract class BaseFragment extends Fragment implements View.OnClickListener {
    protected String mDTag = getClass().getSimpleName();
    protected View viewRoot;
    protected Activity mAty;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mAty = getActivity() ;
        bindViews(inflater, container, savedInstanceState);
        ButterKnife.bind(this,viewRoot);
        return viewRoot;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        EventBus.getDefault().register(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
//        EventBus.getDefault().unregister(this);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
        initViews();
        initEvents();
    }


    protected abstract void bindViews(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);

    protected abstract void initData();

    protected abstract void initViews();

    protected abstract void initEvents();

    protected View getView(@IdRes int resID) {
        return viewRoot.findViewById(resID);
    }
}
